﻿using System;
using System.Collections.Generic;
//using System.ComponentModel.Composition;
//using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.Drawing;
using System.Drawing.Drawing2D;
using TRicheControl.Interface.ControlStyle;
using TRicheControl.DefaultControlStyles.Helper;

namespace TRicheControl.DefaultControlStyles
{
    //[Export(typeof(IButtonStyle))]
    public class ButtonStyle : IButtonStyle
    {
        public void DrawBorder(System.Drawing.Graphics g, System.Drawing.Rectangle rect)
        {
            DrawHelper.SetGraphics(g);
            g.DrawRectangle(new Pen(Color.FromArgb(50, 94, 142)), new Rectangle(0, 0, rect.Width, rect.Height));
        }

        public void DrawMouseEnterStyle(System.Drawing.Graphics g, System.Drawing.Rectangle rect)
        {
            DrawHelper.SetGraphics(g);
            g.FillRectangle(new SolidBrush(Color.FromArgb(40, 94, 142)), new Rectangle(0, 0, rect.Width, rect.Height));
            int width = 1;
            Pen pen = new Pen(Color.FromArgb(60, Color.White), width);
            g.DrawRectangle(pen, new Rectangle(0, 0, rect.Width - width, rect.Height - width));
        }

        public void DrawMouseLeaveStyle(System.Drawing.Graphics g, System.Drawing.Rectangle rect)
        {
            DrawHelper.SetGraphics(g);
            g.FillRectangle(new SolidBrush(Color.FromArgb(48, 113, 169)),new Rectangle(0, 0, rect.Width, rect.Height));
        }

        public void DrawMouseDownStyle(System.Drawing.Graphics g, System.Drawing.Rectangle rect)
        {
            DrawHelper.SetGraphics(g);
            g.FillRectangle(new SolidBrush(Color.FromArgb(100, 94, 142)), rect);
            int width = 3;
            Pen pen = new Pen(Color.FromArgb(100, Color.Black), width);
            //g.DrawLine(pen, new Point(0, width), new Point(rect.Width, width));
            //g.DrawLine(pen, new Point(0, width), new Point(width, rect.Height));
            //g.DrawLine(pen, new Point(rect.Width - width, width), new Point(rect.Width - width, rect.Height));
            g.DrawRectangle(pen, new Rectangle(1, 1, rect.Width - width, rect.Height - width));
        }

        public void DrawGetFocuseStyle(System.Drawing.Graphics g, System.Drawing.Rectangle rect)
        {
        }

        public void DrawLostFocuseStyle(System.Drawing.Graphics g, System.Drawing.Rectangle rect)
        {
        }

        public void DrawUnEnabledStyle(System.Drawing.Graphics g, System.Drawing.Rectangle rect, System.Drawing.Image img)
        {

        }

        public void DrawBackColor(Graphics g, Rectangle rect, Color color)
        {
            DrawHelper.SetGraphics(g);
            g.FillRectangle(new SolidBrush(color), new Rectangle(0, 0, rect.Width, rect.Height));
        }

        public void DrawBackGroundImage(Graphics g, Image image, Rectangle rect, System.Windows.Forms.ImageLayout layout)
        {
            g.DrawImage(image, rect);
        }

        public void DrawEnabelMenuBarItem(Graphics g, Rectangle rect)
        {
            DrawHelper.SetGraphics(g);
            g.Clear(Color.Transparent);
            g.FillRectangle(new SolidBrush(Color.DarkGray),rect);
        }

        public void DrawUnEnabelMenuBarItem(Graphics g, Rectangle rect)
        {
            g.FillRectangle(new SolidBrush(Color.Transparent), rect);
        }

        public void DrawMouseEnterMenuBarItem(Graphics g, Rectangle rect)
        {
            DrawHelper.SetGraphics(g);
            g.Clear(Color.Transparent);
            g.FillRectangle(new SolidBrush(Color.Gray), rect);
            g.DrawRectangle(new Pen(Color.Gray), rect);
        }

        public void DrawMouseDownMenuBarItem(Graphics g, Rectangle rect)
        {
            DrawHelper.SetGraphics(g);
            g.Clear(Color.Transparent);
            g.FillRectangle(new SolidBrush(Color.DarkGray), rect);
            g.DrawRectangle(new Pen(Color.Gray, 2), rect);
        }

        public void DrawMenuBarItemImage(Graphics g, Rectangle rect)
        {
        }

        public void DrawString(string str, Font strFont, Color strColor, Graphics g, Rectangle rect)
        {
            DrawHelper.SetGraphics(g);
            g.DrawString(str, strFont, new SolidBrush(strColor), rect);
        }
    }
}
